1 /* 2 * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation version 2.1 of the License. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 17 * 18 * Based on ETSI EN 300 468 V1.11.1 (2010-04) 19 */ 20 21 /** 22 * @file desc_t2_delivery.h 23 * @ingroup descriptors 24 * @brief Provides the descriptors for the DVB-T2 delivery system descriptor 25 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 26 * @author Mauro Carvalho Chehab 27 * 28 * @par Relevant specs 29 * The descriptor described herein is defined at: 30 * - ETSI EN 300 468 V1.11.1 31 * 32 * @par Bug Report 33 * Please submit bug reports and patches to linux-media@vger.kernel.org 34 */ 35 36 module libdvbv5_d.desc_t2_delivery; 37 38 import libdvbv5_d.desc_extension: dvb_extension_descriptor; 39 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms; 40 41 extern (C): 42 43 /** 44 * @struct dvb_desc_t2_delivery_subcell_old 45 * @ingroup descriptors 46 * @brief Structure to describe transponder subcell extension and frequencies 47 * 48 * @param cell_id_extension cell id extension 49 * @param transposer_frequency transposer frequency 50 * 51 * NOTE: This struct is deprecated and will never be filled. 52 * It is kept here just to avoid breaking ABI. 53 * 54 * All subcell transposer frequencies will be added to 55 * dvb_desc_t2_delivery::centre_frequency array. 56 */ 57 struct dvb_desc_t2_delivery_subcell_old 58 { 59 align (1): 60 61 ubyte cell_id_extension; 62 ushort transposer_frequency; // Should be 32 bits, instead 63 } 64 65 /** 66 * @struct dvb_desc_t2_delivery_subcell 67 * @ingroup descriptors 68 * @brief Structure to describe transponder subcell extension and frequencies 69 * 70 * @param cell_id_extension cell id extension 71 * @param transposer_frequency pointer to transposer frequency 72 */ 73 struct dvb_desc_t2_delivery_subcell 74 { 75 align (1): 76 77 ubyte cell_id_extension; 78 uint transposer_frequency; 79 } 80 81 /** 82 * @struct dvb_desc_t2_delivery_cell 83 * @ingroup descriptors 84 * @brief Structure to describe transponder cells 85 * 86 * @param cell_id cell id extension 87 * @param num_freqs number of cell frequencies 88 * @param centre_frequency pointer to centre frequencies 89 * @param subcel_length number of subcells. May be zero 90 * @param subcell pointer to subcell array. May be NULL 91 */ 92 struct dvb_desc_t2_delivery_cell 93 { 94 align (1): 95 96 ushort cell_id; 97 int num_freqs; 98 uint* centre_frequency; 99 ubyte subcel_length; 100 dvb_desc_t2_delivery_subcell* subcel; 101 } 102 103 /** 104 * @struct dvb_desc_t2_delivery 105 * @ingroup descriptors 106 * @brief Structure containing the T2 delivery system descriptor 107 * 108 * @param plp_id data PLP id 109 * @param system_id T2 system id 110 * @param SISO_MISO SISO MISO 111 * @param bandwidth bandwidth 112 * @param guard_interval guard interval 113 * @param transmission_mode transmission mode 114 * @param other_frequency_flag other frequency flag 115 * @param tfs_flag tfs flag 116 * 117 * @param centre_frequency centre frequency vector. It contains the full 118 * frequencies for all cells and subcells. 119 * @param frequency_loop_length size of the dvb_desc_t2_delivery::centre_frequency 120 * vector 121 * 122 * @param subcel_info_loop_length unused. Always 0 123 * @param subcell unused. Always NULL 124 * @param num_cell number of cells 125 * @param cell cell array. Contains per-cell and per-subcell 126 * pointers to the frequencies parsed. 127 */ 128 struct dvb_desc_t2_delivery 129 { 130 align (1): 131 132 /* extended descriptor */ 133 134 ubyte plp_id; 135 ushort system_id; 136 137 union 138 { 139 align (1): 140 141 ushort bitfield; 142 143 struct 144 { 145 import std.bitmanip : bitfields; 146 align (1): 147 148 mixin(bitfields!( 149 ushort, "tfs_flag", 1, 150 ushort, "other_frequency_flag", 1, 151 ushort, "transmission_mode", 3, 152 ushort, "guard_interval", 3, 153 ushort, "reserved", 2, 154 ushort, "bandwidth", 4, 155 ushort, "SISO_MISO", 2)); 156 } 157 } 158 159 uint* centre_frequency; 160 ubyte frequency_loop_length; 161 162 /* Unused, as the definitions here are incomplete. */ 163 ubyte subcel_info_loop_length; 164 dvb_desc_t2_delivery_subcell_old* subcell; 165 166 /* Since version 1.13 */ 167 uint num_cell; 168 dvb_desc_t2_delivery_cell* cell; 169 } 170 171 // struct dvb_v5_fe_parms; 172 173 /** 174 * @brief Initializes and parses the T2 delivery system descriptor 175 * @ingroup descriptors 176 * 177 * @param parms struct dvb_v5_fe_parms pointer to the opened device 178 * @param buf buffer containing the descriptor's raw data 179 * @param ext struct dvb_extension_descriptor pointer 180 * @param desc pointer to struct dvb_desc to be allocated and filled 181 * 182 * This function allocates a the descriptor and fills the fields inside 183 * the struct. It also makes sure that all fields will follow the CPU 184 * endianness. Due to that, the content of the buffer may change. 185 * 186 * @return On success, it returns the size of the allocated struct. 187 * A negative value indicates an error. 188 */ 189 int dvb_desc_t2_delivery_init ( 190 dvb_v5_fe_parms* parms, 191 const(ubyte)* buf, 192 dvb_extension_descriptor* ext, 193 void* desc); 194 195 /** 196 * @brief Prints the content of the T2 delivery system descriptor 197 * @ingroup descriptors 198 * 199 * @param parms struct dvb_v5_fe_parms pointer to the opened device 200 * @param ext struct dvb_extension_descriptor pointer 201 * @param desc pointer to struct dvb_desc 202 */ 203 void dvb_desc_t2_delivery_print ( 204 dvb_v5_fe_parms* parms, 205 const(dvb_extension_descriptor)* ext, 206 const(void)* desc); 207 208 /** 209 * @brief Frees all data allocated by the T2 delivery system descriptor 210 * @ingroup descriptors 211 * 212 * @param desc pointer to struct dvb_desc to be freed 213 */ 214 void dvb_desc_t2_delivery_free (const(void)* desc); 215 216 /** 217 * @brief converts from internal representation into bandwidth in Hz 218 */ 219 extern __gshared const(uint)[] dvbt2_bw; 220 221 /** 222 * @brief converts from internal representation into enum fe_guard_interval, 223 * as defined at DVBv5 API. 224 */ 225 extern __gshared const(uint)[] dvbt2_interval; 226 227 /** 228 * @brief converts from the descriptor's transmission mode into 229 * enum fe_transmit_mode, as defined by DVBv5 API. 230 */ 231 extern __gshared const(uint)[] dvbt2_transmission_mode; 232 233 /** 234 * @brief converts from internal representation to string the SISO_MISO 235 * field of dvb_desc_t2_delivery:SISO_MISO field. 236 */ 237 extern __gshared const(char)*[4] siso_miso;